package com.klei.controller;

import com.klei.pojo.City;
import com.klei.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class CityController {

    @Autowired
    private ICityService cityService;

    @GetMapping("/getAllCity")
    @ResponseBody
    public List<City> getAllCity(){
        return cityService.getAllCity();
    }

    @GetMapping("/getAllCountry")
    @ResponseBody
    public List<City> getAllCountry(){
        return cityService.getAllCountry();
    }

    @GetMapping("/getCityByPid/{pid}")
    @ResponseBody
    public List<City> getCityByPid(@PathVariable("pid") int pid){
        return cityService.getCityByPid(pid);
    }

    @GetMapping("/getCityById/{id}")
    @ResponseBody
    public City getCityById(@PathVariable("id") int id){
        return cityService.getCityById(id);
    }

}
